package lagou.FileTest;

import java.io.*;

public class BufferCopyByteTest {
    public static void main(String[] args) {
        BufferedInputStream f1 = null;
        BufferedOutputStream f2 = null;
        try {
            f1 = new BufferedInputStream(new FileInputStream("D:/B6UVQ@@8Q6DDI`1X[7~GIRD.png"));
            f2 = new BufferedOutputStream(new FileOutputStream("D:/缓冲区复制的.png"));
            System.out.println("玩命拷贝……");
            byte[] by2 = new byte[1024];
            int res = 0;
            while ((res = f1.read(by2))!= -1){
                f2.write(by2,0,res);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                f2.close();
                f1.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

        }
        System.out.println("OK了家人们");
    }
}
